// 导入封装的axios实例对象
import request from '@/utils/request'

// 登录请求
export const login = (data) => {
	return request({
		url: '/v1_0/authorizations',
		method: 'POST',
		data,
	})
}

// 获取验证码
export const getSmsCode = (mobile) => {
	return request({
		url: '/v1_0/sms/codes/' + mobile,
		method: 'GET',
	})
}

// 获取用户信息
export const getUserProfile = () => {
	return request({
		url: '/v1_0/user',
		method: 'GET',
	})
}


/**
 * 添加关注
 */
 export const addFollow = userId => {
  return request({
    method: 'POST',
    url: '/v1_0/user/followings',
    data: {
      target: userId
    }
  })
}

/**
 * 取消关注
 */
export const deleteFollow = userId => {
  return request({
    method: 'DELETE',
    url: `/v1_0/user/followings/${userId}`
  })
}

// 获取用户资料
export const getUserInfo = ()=>{
  return request({
    method:'GET',
    url:'/v1_0/user/profile'
  })
}

// 获取用户资料(昵称/性别/出生年月)
export const updateUserInfo = data=>{
  return request({
    method:'PATCH',
    url:'/v1_0/user/profile',
    data
  })
}

// 更新用户头像
export const updateUserPhoto = data=>{
  return request({
    method:'PATCH',
    url:'/v1_0/user/photo',
    data
  })
}